package whf.framework.ext.web;

import whf.framework.entity.AbstractEntity;
import whf.framework.ext.entity.Category;
import whf.framework.ext.entity.DictItem;
import whf.framework.ext.service.CategoryServiceImp;
import whf.framework.web.struts.WebData;
import whf.framework.web.struts.WebDispatchAction;
import whf.framework.web.struts.WebForward;

/**
 * @author wanghaifeng
 * @email king@126.com
 * @modify 2006-06-16
 */
public class DictItemAction extends WebDispatchAction {

	/* (non-Javadoc)
	 * @see whf.framework.web.struts.WebDispatchAction#prepareCreate(whf.framework.entity.AbstractEntity, whf.framework.web.struts.WebData)
	 */
	@Override
	public WebForward prepareCreate(AbstractEntity baseForm, WebData data) throws Exception {
		long categoryId = data.getLongParameter("categoryId", 0);
		if(categoryId > 0){
			Category category = CategoryServiceImp.getCategoryService().findByPrimaryKey(categoryId);
			((DictItem)baseForm).setCategory(category);
		}
		return super.prepareCreate(baseForm, data);
	}
} 